package com.kelvem.saas.workbanch.core.base;

import com.kelvem.saas.workbanch.fsm.container.FsmContainer;
import com.kelvem.saas.workbanch.fsm.entity.FsmEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author kelvem
 */
@Slf4j
public class BaseController {
    
    /**
     * trigger event
     *
     * @param entityClazz
     * @param eventCode
     * @param req
     */
    @Transactional(rollbackFor = Exception.class)
    public void trigger(Class<? extends FsmEntity> entityClazz, String eventCode, Object req) {
        log.info("BaseController.trigger[" + eventCode + "] request=" + req);
        FsmContainer.triggerEvent(entityClazz, eventCode, req);
    }
}
